private ["_ctrl","_ok","_units","_index","_XD_display","_children","_nb","_entry_side","_side_name","_side_displayName","_side","_entry_faction","_faction_name","_faction_displayName","_nb_groups","_entry_group"
		,"_group_name","_group_displayName","_arr","_nb_child","_entry_u_group","_u_group_name","_u_group_displayName","_arr2","_i"];
		
if (isnil "SIDE_AI_GROUP_ARRAY") then {
	_unit_class_indexer = [];
	_unit_class_array = [];
	
	_nb = count(configFile >> "CfgVehicles");
	for [{ _i = 0}, { _i < _nb}, { _i = _i + 1}] do {
		if ( isClass( (configFile >> "CfgVehicles") select _i) ) then{
			_entry = (configFile >> "CfgVehicles") select _i;
			if ( isNumber( _entry >> "scope" )) then {
				_scope = getNumber( _entry >> "scope");
				if (_scope == 2) then{
					_name = configName _entry;
					_side = getNumber( _entry >> "side");
					_faction = getText( _entry >> "faction");
					if (_faction == "BIS_BAF") then {
						_faction = "BIS_BAF_MTP";
					};
					_kindof = getText( _entry >> "vehicleclass");
					_displayName = getText( _entry >> "displayName");
					if( _name isKindOf "CAManBase") then {
						_kindof = "MAN";
						_arr = [];
						_arr set [0, _side];
						_arr set [1, _faction];
						_arr set [2, _kindof];
						_arr set [3, _name];
						_arr set [4, _displayName];
						_unit_class_indexer set [count _unit_class_indexer,_name];
						_unit_class_array set [count _unit_class_array, _arr];
					};
				};
			};
		};
	};
	
	SIDE_AI_GROUP_ARRAY = [];
	_nb = count (configFile >> "CfgGroups");
	diag_log Format["Found CfgGroups: %1", _nb];
	for [{_i = 0}, {_i < _nb}, {_i = _i + 1}] do {
		if (isClass ((configFile >> "CfgGroups") select _i)) then {
			_entry_side = ((configFile >> "CfgGroups") select _i);
			_side_name = configName _entry_side;
			_side_displayName = getText(_entry_side >> "name");
			_side = switch (_side_name) do {
				case "East" : {"EAST"};
				case "West" : {"WEST"};
				case "Guerrila" : {"GUER"};
				case "Civilian" : {"CIV"};
				default  {"UNKNOWN"};
			};
			_side_id = switch (_side_name) do {
				case "East" : {0};
				case "West" : {1};
				case "Guerrila" : {2};
				case "Civilian" : {3};
				default  {-1};
			};
			_nb_factions = count _entry_side;
			for [{_z = 0}, {_z < _nb_factions}, {_z = _z + 1}] do {
				if (isClass (_entry_side select _z)) then {
					_entry_faction = (_entry_side select _z);
					_faction_name = configName _entry_faction;
					_faction_displayName = getText(_entry_faction >> "name");
					_arr = [];
					_arr set [count _arr, _side];
					_arr set [count _arr, _side_id];
					_arr set [count _arr, _side_name];
					_arr set [count _arr, _faction_name];
					_arr set [count _arr, _faction_displayName];
					// diag_log Format["(%1)[%2]: %3: %4",diag_tickTime,"grouprequest.sqf","Build Faction",_arr];
					_nb_groups = count _entry_faction;
					_child_group = [];
					for [{_x = 0}, {_x < _nb_groups}, {_x = _x + 1}] do {
						if (isClass (_entry_faction select _x)) then {
							_entry_group = (_entry_faction select _x);
							if (isClass (_entry_group)) then {
								_group_name = configName _entry_group;
								_group_displayName = getText(_entry_group >> "name");
								_arr2 = [];
								_arr2 set [count _arr2, _side];
								_arr2 set [count _arr2, _faction_name];
								_arr2 set [count _arr2, _faction_displayName];
								_arr2 set [count _arr2, _group_name];
								_arr2 set [count _arr2, _group_displayName];
								if (toupper(_group_name) == "INFANTRY") then { 
									// diag_log Format["(%1)[%2]: %3: %4",diag_tickTime,"grouprequest.sqf","Build Group",_arr2];
									_nb_child = count _entry_group;
									_child_unit_group = [];
									for [{_y = 0}, {_y < _nb_child}, {_y = _y + 1}] do {
										if (isClass (_entry_group select _y)) then {
											_entry_u_group = (_entry_group select _y);
											_u_group_name = configName _entry_u_group;
											_u_group_displayName = getText(_entry_u_group >> "name");
											_arr3 = [];
											_arr3 set [count _arr3, _side];
											_arr3 set [count _arr3, _faction_name];
											_arr3 set [count _arr3, _group_name];
											_arr3 set [count _arr3, _u_group_name];
											_arr3 set [count _arr3, _u_group_displayName];
											// diag_log Format["(%1)[%2]: %3: %4",diag_tickTime,"grouprequest.sqf","Build Units",_arr3];

											_nb_units = count _entry_u_group;
											_child_unit = [];
											for [{_z = 0}, {_z < _nb_units}, {_z = _z + 1}] do {
												if (isClass (_entry_u_group select _z)) then {
													_entry_unit = (_entry_u_group select _z);
													_unit_name = configName _entry_unit;
													_unit_type = getText(_entry_unit >> "vehicle");
													_arr4 = [];
													_arr4 set [count _arr4, _side];
													_arr4 set [count _arr4, _faction_name];
													_arr4 set [count _arr4, _group_name];
													_arr4 set [count _arr4, _unit_name];
													_arr4 set [count _arr4, _unit_type];
													
													_idx = _unit_class_indexer find _unit_type;
													if (_idx >= 0) then {
														_arr4 set [count _arr4, (_unit_class_array select _idx)];
													};
													
													_child_unit set [count _child_unit,_arr4];
													// diag_log Format["(%1)[%2]: %3: %4",diag_tickTime,"grouprequest.sqf","Build Unit",_arr4];
												};
											};
											_arr3 set [count _arr3 ,_child_unit];
											_child_unit_group set [count _child_unit_group,_arr3];
										};
									};
									_arr set [count _arr, _child_unit_group];
								};
							};
						};
						_child_group set [count _child_group, _arr2];
					};
					SIDE_AI_GROUP_ARRAY set [count SIDE_AI_GROUP_ARRAY,_arr];
				};
			};		
		};
	};
};

if (!isnil "SIDE_AI_GROUP_ARRAY") then {
	diag_log format["%1",SIDE_AI_GROUP_ARRAY];
	[SIDE_AI_GROUP_ARRAY, "   "] call XfArrayDump;
	hint "groups info dumped!";
};